<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <?php
        //Require your file here
        require_once 'template/pagination.php';
        require_once 'model/works.php';

        //Create global variable
        $md_works = new Works();
        $works = $md_works->select();
        $pagination = new Pagination();
        $total = count($works);
        if (!isset($_GET['page'])) {
            $page = 1;
        } else {
            $page = $_GET['page'];
        }
        $paginations = $pagination->display($total, $page);
        echo $paginations;
        ?>

    </head>
    <body>
        <!-- Include header-->
        <?php include('template/header.php') ?>

        <div class="content">
            <table border="1px;">
                <tr>
                    <td>Id</td>
                    <td>Name </td>
                    <td>Description </td>
                    <td>Image </td>  
                    <td>DK </td>
                </tr>
                <?php foreach ($works as $work): ?>
                    <tr>
                        <td>
                            <?php echo $work['id'] ?>
                        </td>
                        <td>
                            <?php echo $work["name"]; ?>
                        </td>
                        <td>
                            <?php echo substr($work["description"], 0, 70); ?>
                        </td>
                        <td>
                            <img src="<?php echo $work['image']; ?>" width="120px">
                        </td>
                        <td>
                            <a href="#"><?php echo "EDIT" ?></a><br>
                            <a href="#" class="ajax_view" id_works="<?php echo $work['id']; ?>"><?php echo "VIEW" ?></a><br>
                            <a href='#'><?php echo "DELETE" ?></a>
                        </td>                         
                    </tr>
                <?php endforeach; ?>
            </table>
        </div>

        <!-- Include footer-->
        <?php include ('template/footer.php') ?>
    </body>
</html>
